<?php
declare (strict_types=1);

namespace app\exam\model;

use app\common\model\BaseModel;

/**
 * 试题模型
 */
class TopicMaterial extends BaseModel
{
    /**
     * 表名
     *
     * @var string
     */
    protected $name = 'exam_question_topic_material';

    /**
     * 定义字段类型
     * @var [type]
     */
    protected $type = [
        'create_time'   => 'intger',
        'update_time'   => 'intger',
        'question_type' => 'intger'
    ];

    /**
     * append字段
     */
    protected $append = ['question_type_text'];

    public function getQuestionTypeTextAttr($value='', $data)
    {
        $type_arr = self::getQuestionTypeArr();

        return $type_arr[$data['question_type']];
    }

    public static function getQuestionTypeArr()
    {
        return [
            1 => '单选',
            2 => '判断',
            3 => '多选',
            4 => '不定项',
            8 => '简答题',
        ];
    }
}